<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String basePath = request.getContextPath() + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<div class="wrapper wrapper-content">
	<div class="col-xs-12">
		<div class="ibox">
			<div class="ibox-content">
				<form name="FormPost" id="standconvert-addOrUpdate-form"
					class="form-horizontal" method="post" action="" style="width: 100%">
					<!--操作类型  -->
					<input type="hidden" value="${type }" name="type">
					<!--主键  -->
						<input type="hidden" value="${empty standconvert?'':standconvert.stdCodeMapId }"
							name="stdCodeMapId">
					<div class="form-group">
						<label class="col-sm-4 control-label">代码类别:</label>
						<div class="col-sm-7">
								<input type="text" name="stdCatId" id="stdCatId"
									value="${empty standconvert?'':standconvert.stdCatId }" class="form-control"
									datatype="*" nullmsg="代码类别!" required />
								<span style="font-family: Arial, Helvetica, sans-serif; color: #ff0000;" id="check"></span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-4 control-label">源系统:</label>
						<div class="col-sm-7">
								<input type="text" name="srcSys" id="srcSys2"
									value="${empty standconvert?'':standconvert.srcSys }" class="form-control"
									datatype="*" nullmsg="源系统!" required />
								<span style="font-family: Arial, Helvetica, sans-serif; color: #ff0000;" id="check1"></span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-4 control-label">源代码:</label>
						<div class="col-sm-7">
								<input type="text" name="srcCode" id="srcCode2"
									value="${empty standconvert?'':standconvert.srcCode }" class="form-control"
									datatype="*" nullmsg="源代码!" required />
								<span style="font-family: Arial, Helvetica, sans-serif; color: #ff0000;" id="check2"></span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-4 control-label">源代码名称:</label>
						<div class="col-sm-7">
								<input type="text" name="srcCodeName" id="srcCodeName2"
									value="${empty standconvert?'':standconvert.srcCodeName }" class="form-control"
									datatype="*" nullmsg="源代码名称!" required />
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-4 control-label">标准代码:</label>
						<div class="col-sm-7">
								<input type="text" name="stdCode" id="stdCode2"
									value="${empty standconvert?'':standconvert.stdCode }" class="form-control"
									datatype="*" nullmsg="标准代码!" required />
								<span style="font-family: Arial, Helvetica, sans-serif; color: #ff0000;" id="check3"></span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-4 control-label">标准代码名称:</label>
						<div class="col-sm-7">
								<input type="text" name="stdCodeName" id="stdCodeName2"
									value="${empty standconvert?'':standconvert.stdCodeName }" class="form-control"
									datatype="*" nullmsg="标准代码名称!" required />
						</div>
					</div>
						<div class="form-group">
							<label class="col-sm-4 control-label">有效标志:</label>
							<div class="col-sm-7">
								<%--<input type="text" name="validFlag" value="${empty standconvert?'':standconvert.validFlag }"
										id="validFlag" class="form-control" datatype="*"
										nullmsg="有效标志!" required /> --%>
								<select name="validFlag" id="validFlag" class="form-control" datatype="*" >
									<c:if test="${standconvert.validFlag ==1 || empty standconvert.validFlag}">
										<option value="1">是</option>
									</c:if>
									<c:if test="${standconvert.validFlag ==0 || empty standconvert.validFlag}">
										<option value="0">否</option>
									</c:if>
								</select>
							</div>
						</div>
				</form>
			</div>
		</div>
	</div>
</div>
<script>
//æ ¡éª
$("#standconvert-addOrUpdate-form").validate({
	rules : {
		stdCatId : {
			required : true
		},
		srcSys : {
			required : true
		},
		srcCode : {
			required : true
		},
		srcCodeName : {
			required : true
		},
		stdCode : {
			required : true
		},
		stdCodeName : {
			required : true
		},
		validFlag : {
			required : true
		}
	},
	messages : {
		stdCatId : {
			required : "请输入代码类别"
		},
		srcSys : {
			required : "请输入源系统"
		},
		srcCode : {
			required : "请输入原代码"
		},
		srcCodeName : {
			required : "请输入原代码名称"
		},
		stdCode : {
			required : "请输入标准代码"
		},
		stdCodeName : {
			required : "请输入标准代码名称"
		},
		validFlag : {
			required : "请输入有效标志"
		}
	}, 
	ignore: ":hidden:not(.chosen-select)",
	submitHandler : function(form) {
		$("#standconvert-addOrUpdate-form").ajaxSubmit({
			type : 'post',
			url : "<%=basePath%>rest/codemanager/standconvert/saveOrEdit",
				success : function(data) {
					if (data.code == 1) {
						layer.open({
							type : 0,
							time : 800,
							icon : 1,
							content : data.msg,
							btn : 0,
							title : false,
							closeBtn : false,
							skin : 'layui-layer-rim',
							end : function() {
								layer.closeAll();
								//location.reload();
							}
						});
					} else {
						layer.msg(data.msg, {
							time : 2000,
							anim : 6
						});
					}
					var params = jQuery("#search-form").serializeJson();
					$("#table").bootstrapTable("refresh", {query: params});
				}
			});
		}
	});
	

$("#stdCatId").click(function(){
    var params = 
	{
		"type": 1,
		"title": "<i class=\"fa fa-desktop\"></i>&nbsp;添加",
		"zIndex": 199206,
		"shade": [0.5,"#000"],
		"closeBtn": 1,
		"maxmin": false,
		"width": "1200px",
		"height": "",
		"btn": ["<i class=\"ace-icon fa fa-floppy-o middle-120\"></i>&nbsp;确定",
		"<i class=\"ace-icon fa fa-times-circle middle-120\"></i>&nbsp;关 闭"],
		"btnAlign": "c",
		"reloadUrl": false,
		"formId": "datamodel-form",
		"success": null,
		"area": ["1200px",""],
		"yes" : function(){
			var select = $("#table1").bootstrapTable("getSelections");
			$("#stdCatId").val(select[0].stdCatType);
			layer.close(layer.index);
		}
    }
    $.ajax({
    	url:"<%=basePath%>rest/codemanager/standconvert/toCodeTypeList",
    	async:false,
    	success:function(data){
    		params.content = data;
    	}
    });
    layer.open(params);
})


$("#stdCode2").click(function(){
	var index;
    var params = 
	{
		"type": 1,
		"title": "<i class=\"fa fa-desktop\"></i>&nbsp;添加",
		"zIndex": 199206,
		"shade": [0.5,"#000"],
		"closeBtn": 1,
		"maxmin": false,
		"width": "900px",
		"height": "",
		"btn": ["<i class=\"ace-icon fa fa-floppy-o middle-120\"></i>&nbsp;确定",
		"<i class=\"ace-icon fa fa-times-circle middle-120\"></i>&nbsp;关 闭"],
		"btnAlign": "c",
		"reloadUrl": false,
		"formId": "datamodel-form",
		"success": null,
		"area": ["900px","500px"],
		"yes" : function(){
			var select = $("#table2").bootstrapTable("getSelections");
			$("#stdCode2").val(select[0].stdCode);
			$("#stdCodeName2").val(select[0].stdCodeName);
			layer.close(index);
		}
    }
    $.ajax({
    	url:"<%=basePath%>rest/codemanager/standconvert/toStandCodeList",
    	async:false,
    	success:function(data){
    		params.content = data;
    	}
    });
    index = layer.open(params);
})


$("#srcSys2").click(function(){
	var index;
    var params = 
	{
		"type": 1,
		"title": "<i class=\"fa fa-desktop\"></i>&nbsp;添加",
		"zIndex": 199206,
		"shade": [0.5,"#000"],
		"closeBtn": 1,
		"maxmin": false,
		"width": "1200px",
		"height": "",
		"btn": ["<i class=\"ace-icon fa fa-floppy-o middle-120\"></i>&nbsp;确定",
		"<i class=\"ace-icon fa fa-times-circle middle-120\"></i>&nbsp;关 闭"],
		"btnAlign": "c",
		"reloadUrl": false,
		"formId": "datamodel-form",
		"success": null,
		"area": ["1200px","500px"],
		"yes" : function(){
			var select = $("#table3").bootstrapTable("getSelections");
			$("#srcSys2").val(select[0].srcSys);
			$("#srcCode2").val(select[0].srcCode);
			$("#srcCodeName2").val(select[0].srcCodeName);
			layer.close(index);
		}
    }
    $.ajax({
    	url:"<%=basePath%>rest/codemanager/standconvert/toSystemList",
    	async:false,
    	success:function(data){
    		params.content = data;
    	}
    });
    index = layer.open(params);
})


$("#srcCode2").click(function(){
	var index;
    var params = 
	{
		"type": 1,
		"title": "<i class=\"fa fa-desktop\"></i>&nbsp;添加",
		"zIndex": 199206,
		"shade": [0.5,"#000"],
		"closeBtn": 1,
		"maxmin": false,
		"width": "1200px",
		"height": "",
		"btn": ["<i class=\"ace-icon fa fa-floppy-o middle-120\"></i>&nbsp;确定",
		"<i class=\"ace-icon fa fa-times-circle middle-120\"></i>&nbsp;关 闭"],
		"btnAlign": "c",
		"reloadUrl": false,
		"formId": "datamodel-form",
		"success": null,
		"area": ["1200px","500px"],
		"yes" : function(){
			var select = $("#table3").bootstrapTable("getSelections");
			$("#srcSys2").val(select[0].srcSys);
			$("#srcCode2").val(select[0].srcCode);
			$("#srcCodeName2").val(select[0].srcCodeName);
			layer.close(index);
		}
    }
    $.ajax({
    	url:"<%=basePath%>rest/codemanager/standconvert/toSystemList",
    	async:false,
    	success:function(data){
    		params.content = data;
    	}
    });
    index = layer.open(params);
})

<%-- $('input#stdCode2').change(function(){
	var stdCatId = $("#stdCatId").val();
  	var srcSys = $("#srcSys").val();
  	var srcCode = $("#srcCode2").val();
  	var stdCode = $(this).val();
	  	 $.ajax({
	   	     async:false,//改为同步
	   	     type: "POST",
	   	     url: "<%=basePath%>rest/codemanager/standconvert/onlyone",
	   	     data: {stdCatId:stdCatId,srcSys:srcSys,srcCode:srcCode,stdCode:stdCode},
	   	     dataType: "json",
	   	     success: function (result) {
	   	         if(result!=null){
	   	             alert("【代码类别、源系统、源代码、标准代码】组合已存在!")
	   	             return false;
	   	         }
	   	     }
	   	 });
}); --%>

$(document).on('click', '.layui-layer-btn0', function(){
	$("#standconvert-addOrUpdate-form").valid();
})
</script>